/*!
 * js-sdsl v4.2.0
 * https://github.com/js-sdsl/js-sdsl
 * (c) 2021-present ZLY201 <zilongyao1366@gmail.com>
 * MIT license
 */
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var k=function(t,i){return(k=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,i){t.__proto__=i}:function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}))(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}k(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}function r(e,n){var s,o,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},p={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(p[Symbol.iterator]=function(){return this}),p;function t(r){return function(t){var i=[r,t];if(s)throw new TypeError("Generator is already executing.");for(;u=p&&i[p=0]?0:u;)try{if(s=1,o&&(h=2&i[0]?o.return:i[0]?o.throw||((h=o.return)&&h.call(o),0):o.next)&&!(h=h.call(o,i[1])).done)return h;switch(o=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]<h[3]))u.label=i[1];else if(6===i[0]&&u.label<h[1])u.label=h[1],h=i;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(i)}}i=n.call(e,u)}catch(t){i=[6,t],o=0}finally{s=h=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function u(t){var i="function"==typeof Symbol&&Symbol.iterator,r=i&&t[i],e=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,i){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,n,s=r.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){n={error:t}}finally{try{e&&!e.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function p(t,i,r){if(r||2===arguments.length)for(var e,n=0,s=i.length;n<s;n++)!e&&n in i||((e=e||Array.prototype.slice.call(i,0,n))[n]=i[n]);return t.concat(e||Array.prototype.slice.call(i))}O.prototype.equals=function(t){return this.t===t.t};var e=O;function O(t){this.iteratorType=t=void 0===t?0:t}Object.defineProperty(S.prototype,"length",{get:function(){return this.i},enumerable:!1,configurable:!0}),S.prototype.size=function(){return this.i},S.prototype.empty=function(){return 0===this.i};var n=S;function S(){this.i=0}i(T,N=n);var N,_=T;function T(){return null!==N&&N.apply(this,arguments)||this}i(s,I=n),s.prototype.clear=function(){this.i=0,this.h=[]},s.prototype.push=function(t){return this.h.push(t),this.i+=1,this.i},s.prototype.pop=function(){if(0!==this.i)return--this.i,this.h.pop()},s.prototype.top=function(){return this.h[this.i-1]};var I,q=s;function s(t){void 0===t&&(t=[]);var i=I.call(this)||this,r=(i.h=[],i);return t.forEach(function(t){r.push(t)}),i}i(L,M=_);var M,H=L;function L(){return null!==M&&M.apply(this,arguments)||this}function o(){throw new RangeError("Iterator access denied!")}i(W,z=e),Object.defineProperty(W.prototype,"pointer",{get:function(){if(this.t<0||this.t>this.u()-1)throw new RangeError;return this.o(this.t)},set:function(t){if(this.t<0||this.t>this.u()-1)throw new RangeError;this.v(this.t,t)},enumerable:!1,configurable:!0});var z,Y=W;function W(t,i,r,e,n){n=z.call(this,n)||this;return n.t=t,n.u=i,n.o=r,n.v=e,0===n.iteratorType?(n.pre=function(){return 0===this.t&&o(),--this.t,this},n.next=function(){return this.t===this.u()&&o(),this.t+=1,this}):(n.pre=function(){return this.t===this.u()-1&&o(),this.t+=1,this},n.next=function(){return-1===this.t&&o(),--this.t,this}),n}i(Z,X=Y),Z.prototype.copy=function(){return new Z(this.t,this.u,this.o,this.v,this.iteratorType)};var X,f=Z;function Z(){return null!==X&&X.apply(this,arguments)||this}i(c,C=H),c.prototype.k=function(){for(var t=[],i=Math.max(this.S>>1,1),r=0;r<i;++r)t[r]=new Array(this.O);for(r=this.l;r<this.S;++r)t[t.length]=this.L[r];for(r=0;r<this.p;++r)t[t.length]=this.L[r];t[t.length]=p([],h(this.L[this.p]),!1),this.l=i,this.p=t.length-1;for(r=0;r<i;++r)t[t.length]=new Array(this.O);this.L=t,this.S=t.length},c.prototype.g=function(t){var t=this._+t+1,i=t%this.O,r=i-1,t=this.l+(t-i)/this.O;return 0==i&&--t,t%=this.S,r<0&&(r+=this.O),{curNodeBucketIndex:t,curNodePointerIndex:r}},c.prototype.clear=function(){this.L=[[]],this.S=1,this.l=this.p=this.i=0,this._=this.I=this.O>>1},c.prototype.begin=function(){return new f(0,this.size,this.getElementByPos,this.setElementByPos)},c.prototype.end=function(){return new f(this.i,this.size,this.getElementByPos,this.setElementByPos)},c.prototype.rBegin=function(){return new f(this.i-1,this.size,this.getElementByPos,this.setElementByPos,1)},c.prototype.rEnd=function(){return new f(-1,this.size,this.getElementByPos,this.setElementByPos,1)},c.prototype.front=function(){return this.L[this.l][this._]},c.prototype.back=function(){return this.L[this.p][this.I]},c.prototype.pushBack=function(t){return this.i&&(this.I<this.O-1?this.I+=1:(this.p<this.S-1?this.p+=1:this.p=0,this.I=0),this.p===this.l)&&this.I===this._&&this.k(),this.i+=1,this.L[this.p][this.I]=t,this.i},c.prototype.popBack=function(){var t;if(0!==this.i)return t=this.L[this.p][this.I],delete this.L[this.p][this.I],1!==this.i&&(0<this.I?--this.I:(0<this.p?--this.p:this.p=this.S-1,this.I=this.O-1)),--this.i,t},c.prototype.pushFront=function(t){return this.i&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.S-1,this._=this.O-1),this.l===this.p)&&this._===this.I&&this.k(),this.i+=1,this.L[this.l][this._]=t,this.i},c.prototype.popFront=function(){var t;if(0!==this.i)return t=this.L[this.l][this._],delete this.L[this.l][this._],1!==this.i&&(this._<this.O-1?this._+=1:(this.l<this.S-1?this.l+=1:this.l=0,this._=0)),--this.i,t},c.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;var t=this.g(t),i=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.L[i][t]},c.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;var t=this.g(t),r=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.L[r][t]=i},c.prototype.insert=function(t,i,r){if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;if(0===t)for(;r--;)this.pushFront(i);else if(t===this.i)for(;r--;)this.pushBack(i);else{for(var e=[],n=t;n<this.i;++n)e.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<r;++n)this.pushBack(i);for(n=0;n<e.length;++n)this.pushBack(e[n])}return this.i},c.prototype.cut=function(t){var i,r;return t<0?(this.clear(),0):(i=(r=this.g(t)).curNodeBucketIndex,r=r.curNodePointerIndex,this.p=i,this.I=r,this.i=t+1,this.i)},c.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;if(0===t)this.popFront();else if(t===this.i-1)this.popBack();else{for(var i=[],r=t+1;r<this.i;++r)i.push(this.getElementByPos(r));this.cut(t),this.popBack();var e=this;i.forEach(function(t){e.pushBack(t)})}return this.i},c.prototype.eraseElementByValue=function(t){if(0===this.i)return 0;for(var i=[],r=0;r<this.i;++r){var e=this.getElementByPos(r);e!==t&&i.push(e)}for(var n=i.length,r=0;r<n;++r)this.setElementByPos(r,i[r]);return this.cut(n-1)},c.prototype.eraseElementByIterator=function(t){var i=t.t;return this.eraseElementByPos(i),t=t.next()},c.prototype.find=function(t){for(var i=0;i<this.i;++i)if(this.getElementByPos(i)===t)return new f(i,this.size,this.getElementByPos,this.setElementByPos);return this.end()},c.prototype.reverse=function(){for(var t=0,i=this.i-1;t<i;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(i)),this.setElementByPos(i,r),t+=1,--i}},c.prototype.unique=function(){if(!(this.i<=1)){for(var t=1,i=this.getElementByPos(0),r=1;r<this.i;++r){var e=this.getElementByPos(r);e!==i&&this.setElementByPos(t++,i=e)}for(;this.i>t;)this.popBack()}return this.i},c.prototype.sort=function(t){for(var i=[],r=0;r<this.i;++r)i.push(this.getElementByPos(r));i.sort(t);for(r=0;r<this.i;++r)this.setElementByPos(r,i[r])},c.prototype.shrinkToFit=function(){if(0!==this.i){var i=[];this.forEach(function(t){i.push(t)}),this.S=Math.max(Math.ceil(this.i/this.O),1),this.i=this.l=this.p=this._=this.I=0,this.L=[];for(var t=0;t<this.S;++t)this.L.push(new Array(this.O));for(t=0;t<i.length;++t)this.pushBack(i[t])}},c.prototype.forEach=function(t){for(var i=0;i<this.i;++i)t(this.getElementByPos(i),i,this)},c.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:i=0,t.label=1;case 1:return i<this.i?[4,this.getElementByPos(i)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++i,[3,1];case 4:return[2]}})}.bind(this)()};var C,Q=c;function c(t,i){void 0===t&&(t=[]),void 0===i&&(i=4096);var r,e=C.call(this)||this;if(e.l=0,e._=0,e.p=0,e.I=0,e.S=0,e.L=[],"size"in t)r="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");r=t.length}e.O=i,e.S=Math.max(Math.ceil(r/e.O),1);for(var n=0;n<e.S;++n)e.L.push(new Array(e.O));var i=Math.ceil(r/e.O),s=(e.l=e.p=(e.S>>1)-(i>>1),e._=e.I=e.O-r%e.O>>1,e);return t.forEach(function(t){s.pushBack(t)}),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}i(a,tt=n),a.prototype.clear=function(){this.H.clear(),this.i=0},a.prototype.push=function(t){return this.H.pushBack(t),this.i+=1,this.i},a.prototype.pop=function(){if(0!==this.i)return--this.i,this.H.popFront()},a.prototype.front=function(){return this.H.front()};var tt,it=a;function a(t){void 0===t&&(t=[]);var i=tt.call(this)||this;return i.H=new Q(t),i.i=i.H.size(),i}i(l,rt=n),l.prototype.T=function(t){for(var i=this.A[t];0<t;){var r=t-1>>1,e=this.A[r];if(this.M(e,i)<=0)break;this.A[t]=e,t=r}this.A[t]=i},l.prototype.C=function(t,i){for(var r=this.A[t];t<i;){var e=t<<1|1,n=e+1,s=this.A[e];if(n<this.i&&0<this.M(s,this.A[n])&&(s=this.A[e=n]),0<=this.M(s,r))break;this.A[t]=s,t=e}this.A[t]=r},l.prototype.clear=function(){this.i=0,this.A.length=0},l.prototype.push=function(t){this.A.push(t),this.T(this.i),this.i+=1},l.prototype.pop=function(){var t,i;if(0!==this.i)return t=this.A[0],i=this.A.pop(),--this.i,this.i&&(this.A[0]=i,this.C(0,this.i>>1)),t},l.prototype.top=function(){return this.A[0]},l.prototype.find=function(t){return 0<=this.A.indexOf(t)},l.prototype.remove=function(t){t=this.A.indexOf(t);return!(t<0||(0===t?this.pop():t===this.i-1?(this.A.pop(),--this.i):(this.A.splice(t,1,this.A.pop()),--this.i,this.T(t),this.C(t,this.i>>1)),0))},l.prototype.updateItem=function(t){t=this.A.indexOf(t);return!(t<0||(this.T(t),this.C(t,this.i>>1),0))},l.prototype.toArray=function(){return p([],h(this.A),!1)};var rt,n=l;function l(t,i,r){void 0===t&&(t=[]),void 0===i&&(i=function(t,i){return i<t?-1:t<i?1:0}),void 0===r&&(r=!0);for(var e,n=rt.call(this)||this,s=(n.M=i,Array.isArray(t)?n.A=r?p([],h(t),!1):t:(n.A=[],e=n,t.forEach(function(t){e.A.push(t)})),n.i=n.A.length,n.i>>1),o=n.i-1>>1;0<=o;--o)n.C(o,s);return n}i(nt,et=Y),nt.prototype.copy=function(){return new nt(this.t,this.u,this.o,this.v,this.iteratorType)};var et,y=nt;function nt(){return null!==et&&et.apply(this,arguments)||this}i(v,st=H),v.prototype.clear=function(){this.i=0,this.q.length=0},v.prototype.begin=function(){return new y(0,this.size,this.getElementByPos,this.setElementByPos)},v.prototype.end=function(){return new y(this.i,this.size,this.getElementByPos,this.setElementByPos)},v.prototype.rBegin=function(){return new y(this.i-1,this.size,this.getElementByPos,this.setElementByPos,1)},v.prototype.rEnd=function(){return new y(-1,this.size,this.getElementByPos,this.setElementByPos,1)},v.prototype.front=function(){return this.q[0]},v.prototype.back=function(){return this.q[this.i-1]},v.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.q[t]},v.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.q.splice(t,1),--this.i,this.i},v.prototype.eraseElementByValue=function(t){for(var i=0,r=0;r<this.i;++r)this.q[r]!==t&&(this.q[i++]=this.q[r]);return this.i=this.q.length=i,this.i},v.prototype.eraseElementByIterator=function(t){var i=t.t;return t=t.next(),this.eraseElementByPos(i),t},v.prototype.pushBack=function(t){return this.q.push(t),this.i+=1,this.i},v.prototype.popBack=function(){if(0!==this.i)return--this.i,this.q.pop()},v.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;this.q[t]=i},v.prototype.insert=function(t,i,r){var e;if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;return(e=this.q).splice.apply(e,p([t,0],h(new Array(r).fill(i)),!1)),this.i+=r,this.i},v.prototype.find=function(t){for(var i=0;i<this.i;++i)if(this.q[i]===t)return new y(i,this.size,this.getElementByPos,this.getElementByPos);return this.end()},v.prototype.reverse=function(){this.q.reverse()},v.prototype.unique=function(){for(var t=1,i=1;i<this.i;++i)this.q[i]!==this.q[i-1]&&(this.q[t++]=this.q[i]);return this.i=this.q.length=t,this.i},v.prototype.sort=function(t){this.q.sort(t)},v.prototype.forEach=function(t){for(var i=0;i<this.i;++i)t(this.q[i],i,this)},v.prototype[Symbol.iterator]=function(){return function(){return r(this,function(t){switch(t.label){case 0:return[5,u(this.q)];case 1:return t.sent(),[2]}})}.bind(this)()};var st,Y=v;function v(t,i){void 0===t&&(t=[]),void 0===i&&(i=!0);var r,e=st.call(this)||this;return Array.isArray(t)?(e.q=i?p([],h(t),!1):t,e.i=t.length):(e.q=[],r=e,t.forEach(function(t){r.pushBack(t)})),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}i(D,ot=e),Object.defineProperty(D.prototype,"pointer",{get:function(){return this.t===this.D&&o(),this.t.R},set:function(t){this.t===this.D&&o(),this.t.R=t},enumerable:!1,configurable:!0}),D.prototype.copy=function(){return new D(this.t,this.D,this.iteratorType)};var ot,d=D;function D(t,i,r){r=ot.call(this,r)||this;return r.t=t,r.D=i,0===r.iteratorType?(r.pre=function(){return this.t.m===this.D&&o(),this.t=this.t.m,this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.V,this}):(r.pre=function(){return this.t.V===this.D&&o(),this.t=this.t.V,this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.m,this}),r}i(w,ht=H),w.prototype.P=function(t){var i=t.m,r=t.V;(i.V=r).m=i,t===this.j&&(this.j=r),t===this.N&&(this.N=i),--this.i},w.prototype.B=function(t,i){var r=i.V,t={R:t,m:i,V:r};i.V=t,r.m=t,i===this.D&&(this.j=t),r===this.D&&(this.N=t),this.i+=1},w.prototype.clear=function(){this.i=0,this.j=this.N=this.D.m=this.D.V=this.D},w.prototype.begin=function(){return new d(this.j,this.D)},w.prototype.end=function(){return new d(this.D,this.D)},w.prototype.rBegin=function(){return new d(this.N,this.D,1)},w.prototype.rEnd=function(){return new d(this.D,this.D,1)},w.prototype.front=function(){return this.j.R},w.prototype.back=function(){return this.N.R},w.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return i.R},w.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return this.P(i),this.i},w.prototype.eraseElementByValue=function(t){for(var i=this.j;i!==this.D;)i.R===t&&this.P(i),i=i.V;return this.i},w.prototype.eraseElementByIterator=function(t){var i=t.t;return i===this.D&&o(),t=t.next(),this.P(i),t},w.prototype.pushBack=function(t){return this.B(t,this.N),this.i},w.prototype.popBack=function(){var t;if(0!==this.i)return t=this.N.R,this.P(this.N),t},w.prototype.pushFront=function(t){return this.B(t,this.D),this.i},w.prototype.popFront=function(){var t;if(0!==this.i)return t=this.j.R,this.P(this.j),t},w.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;for(var r=this.j;t--;)r=r.V;r.R=i},w.prototype.insert=function(t,i,r){if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;if(!(r<=0))if(0===t)for(;r--;)this.pushFront(i);else if(t===this.i)for(;r--;)this.pushBack(i);else{for(var e=this.j,n=1;n<t;++n)e=e.V;var s=e.V;for(this.i+=r;r--;)e.V={R:i,m:e},e=(e.V.m=e).V;(e.V=s).m=e}return this.i},w.prototype.find=function(t){for(var i=this.j;i!==this.D;){if(i.R===t)return new d(i,this.D);i=i.V}return this.end()},w.prototype.reverse=function(){if(!(this.i<=1))for(var t=this.j,i=this.N,r=0;r<<1<this.i;){var e=t.R;t.R=i.R,i.R=e,t=t.V,i=i.m,r+=1}},w.prototype.unique=function(){if(!(this.i<=1))for(var t=this.j;t!==this.D;){for(var i=t;i.V!==this.D&&i.R===i.V.R;)i=i.V,--this.i;t.V=i.V,t=(t.V.m=t).V}return this.i},w.prototype.sort=function(t){var i,r;this.i<=1||(i=[],this.forEach(function(t){i.push(t)}),i.sort(t),r=this.j,i.forEach(function(t){r.R=t,r=r.V}))},w.prototype.merge=function(t){var i,r=this;return 0===this.i?t.forEach(function(t){r.pushBack(t)}):(i=this.j,t.forEach(function(t){for(;i!==r.D&&i.R<=t;)i=i.V;r.B(t,i.m)})),this.i},w.prototype.forEach=function(t){for(var i=this.j,r=0;i!==this.D;)t(i.R,r++,this),i=i.V},w.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:if(0===this.i)return[2];i=this.j,t.label=1;case 1:return i===this.D?[3,3]:[4,i.R];case 2:return t.sent(),i=i.V,[3,1];case 3:return[2]}})}.bind(this)()};var ht,H=w;function w(t){void 0===t&&(t=[]);var i=ht.call(this)||this,r=(i.D={},i.j=i.N=i.D.m=i.D.V=i.D,i);return t.forEach(function(t){r.pushBack(t)}),i}m.prototype.m=function(){var t=this;if(1===t.G&&t.U.U===t)t=t.K;else if(t.J)for(t=t.J;t.K;)t=t.K;else{for(var i=t.U;i.J===t;)i=(t=i).U;t=i}return t},m.prototype.V=function(){var t=this;if(t.K){for(t=t.K;t.J;)t=t.J;return t}for(var i=t.U;i.K===t;)i=(t=i).U;return t.K!==i?i:t},m.prototype.W=function(){var t=this.U,i=this.K,r=i.J;return t.U===this?t.U=i:t.J===this?t.J=i:t.K=i,i.U=t,(i.J=this).U=i,(this.K=r)&&(r.U=this),i},m.prototype.X=function(){var t=this.U,i=this.J,r=i.K;return t.U===this?t.U=i:t.J===this?t.J=i:t.K=i,i.U=t,(i.K=this).U=i,(this.J=r)&&(r.U=this),i};var ut=m;function m(t,i){this.G=1,this.F=void 0,this.R=void 0,this.J=void 0,this.K=void 0,this.U=void 0,this.F=t,this.R=i}i(g,E=ut),g.prototype.W=function(){var t=E.prototype.W.call(this);return this.Z(),t.Z(),t},g.prototype.X=function(){var t=E.prototype.X.call(this);return this.Z(),t.Z(),t},g.prototype.Z=function(){this.Y=1,this.J&&(this.Y+=this.J.Y),this.K&&(this.Y+=this.K.Y)};var E,pt=g;function g(){var t=null!==E&&E.apply(this,arguments)||this;return t.Y=1,t}i(b,ft=_),b.prototype.st=function(t,i){for(var r=this.D;t;){var e=this.M(t.F,i);if(e<0)t=t.K;else{if(!(0<e))return t;t=(r=t).J}}return r},b.prototype.ht=function(t,i){for(var r=this.D;t;)t=this.M(t.F,i)<=0?t.K:(r=t).J;return r},b.prototype.ut=function(t,i){for(var r=this.D;t;){var e=this.M(t.F,i);if(e<0)t=(r=t).K;else{if(!(0<e))return t;t=t.J}}return r},b.prototype.ot=function(t,i){for(var r=this.D;t;)t=this.M(t.F,i)<0?(r=t).K:t.J;return r},b.prototype.ft=function(t){for(;;){var i,r=t.U;if(r===this.D)return;if(1===t.G)return void(t.G=0);if(t===r.J)if(1===(i=r.K).G)i.G=0,r.G=1,r===this.$?this.$=r.W():r.W();else{if(i.K&&1===i.K.G)return i.G=r.G,r.G=0,i.K.G=0,void(r===this.$?this.$=r.W():r.W());i.J&&1===i.J.G?(i.G=1,i.J.G=0,i.X()):(i.G=1,t=r)}else if(1===(i=r.J).G)i.G=0,r.G=1,r===this.$?this.$=r.X():r.X();else{if(i.J&&1===i.J.G)return i.G=r.G,r.G=0,i.J.G=0,void(r===this.$?this.$=r.X():r.X());i.K&&1===i.K.G?(i.G=1,i.K.G=0,i.W()):(i.G=1,t=r)}}},b.prototype.nt=function(t){var i;if(1===this.i)return this.clear(),this.D;for(var r=t;r.J||r.K;){if(r.K)for(r=r.K;r.J;)r=r.J;else r=r.J;i=h([r.F,t.F],2),t.F=i[0],r.F=i[1],i=h([r.R,t.R],2),t.R=i[0],r.R=i[1],t=r}this.D.J===r?this.D.J=r.U:this.D.K===r&&(this.D.K=r.U),this.ft(r);var e=r.U;return r===e.J?e.J=void 0:e.K=void 0,--this.i,this.$.G=0,e},b.prototype.ct=function(t,i){return void 0!==t&&(!!this.ct(t.J,i)||!!i(t)||this.ct(t.K,i))},b.prototype.et=function(t){for(;;){var i=t.U;if(0===i.G)return;var r,e,n=i.U;if(i===n.J){if((r=n.K)&&1===r.G){if(r.G=i.G=0,n===this.$)return;n.G=1,t=n;continue}if(t===i.K)return t.G=0,t.J&&(t.J.U=i),t.K&&(t.K.U=n),i.K=t.J,n.J=t.K,t.J=i,(t.K=n)===this.$?(this.$=t,this.D.U=t):(e=n.U).J===n?e.J=t:e.K=t,t.U=n.U,i.U=t,n.U=t,n.G=1,{parentNode:i,grandParent:n,curNode:t};i.G=0,n===this.$?this.$=n.X():n.X()}else{if((r=n.J)&&1===r.G){if(r.G=i.G=0,n===this.$)return;n.G=1,t=n;continue}if(t===i.J)return t.G=0,t.J&&(t.J.U=n),t.K&&(t.K.U=i),n.K=t.J,i.J=t.K,t.J=n,t.K=i,n===this.$?(this.$=t,this.D.U=t):(e=n.U).J===n?e.J=t:e.K=t,t.U=n.U,i.U=t,n.U=t,n.G=1,{parentNode:i,grandParent:n,curNode:t};i.G=0,n===this.$?this.$=n.W():n.W()}return void(n.G=1)}},b.prototype.rt=function(t,i,r){if(void 0===this.$)this.i+=1,this.$=new this.tt(t,i),this.$.G=0,this.$.U=this.D,this.D.U=this.$,this.D.J=this.$,this.D.K=this.$;else{var e,n=this.D.J,s=this.M(n.F,t);if(0!==s){if(0<s)n.J=new this.tt(t,i),e=(n.J.U=n).J,this.D.J=e;else{var s=this.D.K,o=this.M(s.F,t);if(0===o)return void(s.R=i);if(o<0)s.K=new this.tt(t,i),e=(s.K.U=s).K,this.D.K=e;else{if(void 0!==r){o=r.t;if(o!==this.D){s=this.M(o.F,t);if(0===s)return void(o.R=i);if(0<s){r=o.m(),s=this.M(r.F,t);if(0===s)return void(r.R=i);s<0&&(e=new this.tt(t,i),void 0===r.K?(r.K=e).U=r:(o.J=e).U=o)}}}if(void 0===e)for(e=this.$;;){var h=this.M(e.F,t);if(0<h){if(void 0===e.J){e.J=new this.tt(t,i),e=(e.J.U=e).J;break}e=e.J}else{if(!(h<0))return void(e.R=i);if(void 0===e.K){e.K=new this.tt(t,i),e=(e.K.U=e).K;break}e=e.K}}}}return this.i+=1,e}n.R=i}},b.prototype.vt=function(t,i){for(;t;){var r=this.M(t.F,i);if(r<0)t=t.K;else{if(!(0<r))return t;t=t.J}}return t||this.D},b.prototype.clear=function(){this.i=0,this.$=void 0,this.D.U=void 0,this.D.J=this.D.K=void 0},b.prototype.updateKeyByIterator=function(t,i){t=t.t;if(t===this.D&&o(),1!==this.i){if(t===this.D.J)return 0<this.M(t.V().F,i)&&(t.F=i,!0);if(t===this.D.K)return this.M(t.m().F,i)<0&&(t.F=i,!0);var r=t.m().F;if(0<=this.M(r,i))return!1;if(r=t.V().F,this.M(r,i)<=0)return!1}return t.F=i,!0},b.prototype.eraseElementByPos=function(i){if(i<0||i>this.i-1)throw new RangeError;var r=0,e=this;return this.ct(this.$,function(t){return i===r?(e.P(t),!0):(r+=1,!1)}),this.i},b.prototype.eraseElementByKey=function(t){return 0!==this.i&&(t=this.vt(this.$,t))!==this.D&&(this.P(t),!0)},b.prototype.eraseElementByIterator=function(t){var i=t.t,r=(i===this.D&&o(),void 0===i.K);return 0===t.iteratorType?r&&t.next():r&&void 0!==i.J||t.next(),this.P(i),t},b.prototype.forEach=function(t){var i,r,e=0;try{for(var n=u(this),s=n.next();!s.done;s=n.next())t(s.value,e++,this)}catch(t){i={error:t}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}},b.prototype.getElementByPos=function(t){var i,r,e;if(t<0||t>this.i-1)throw new RangeError;var n=0;try{for(var s=u(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){e=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return e},b.prototype.getHeight=function(){var i;return 0===this.i?0:(i=function(t){return t?Math.max(i(t.J),i(t.K))+1:0})(this.$)};var ft,B=b;function b(t,i){void 0===t&&(t=function(t,i){return t<i?-1:i<t?1:0}),void 0===i&&(i=!1);var r=ft.call(this)||this;return r.$=void 0,r.M=t,i?(r.tt=pt,r.it=function(t,i,r){t=this.rt(t,i,r);if(t){for(var e=t.U;e!==this.D;)e.Y+=1,e=e.U;var i=this.et(t);i&&(r=i.parentNode,t=i.grandParent,i=i.curNode,r.Z(),t.Z(),i.Z())}return this.i},r.P=function(t){for(var i=this.nt(t);i!==this.D;)--i.Y,i=i.U}):(r.tt=ut,r.it=function(t,i,r){t=this.rt(t,i,r);return t&&this.et(t),this.i},r.P=r.nt),r.D=new r.tt,r}i(lt,ct=e),Object.defineProperty(lt.prototype,"index",{get:function(){var t=this.t,i=this.D.U;if(t===this.D)return i?i.Y-1:0;var r=0;for(t.J&&(r+=t.J.Y);t!==i;){var e=t.U;t===e.K&&(r+=1,e.J)&&(r+=e.J.Y),t=e}return r},enumerable:!1,configurable:!0});var ct,at=lt;function lt(t,i,r){r=ct.call(this,r)||this;return r.t=t,r.D=i,0===r.iteratorType?(r.pre=function(){return this.t===this.D.J&&o(),this.t=this.t.m(),this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.V(),this}):(r.pre=function(){return this.t===this.D.K&&o(),this.t=this.t.V(),this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.m(),this}),r}i(J,yt=at),Object.defineProperty(J.prototype,"pointer",{get:function(){return this.t===this.D&&o(),this.t.F},enumerable:!1,configurable:!0}),J.prototype.copy=function(){return new J(this.t,this.D,this.iteratorType)};var yt,P=J;function J(){return null!==yt&&yt.apply(this,arguments)||this}i(K,vt=B),K.prototype.dt=function(i){return r(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,u(this.dt(i.J))];case 1:return t.sent(),[4,i.F];case 2:return t.sent(),[5,u(this.dt(i.K))];case 3:return t.sent(),[2]}})},K.prototype.begin=function(){return new P(this.D.J||this.D,this.D)},K.prototype.end=function(){return new P(this.D,this.D)},K.prototype.rBegin=function(){return new P(this.D.K||this.D,this.D,1)},K.prototype.rEnd=function(){return new P(this.D,this.D,1)},K.prototype.front=function(){return this.D.J?this.D.J.F:void 0},K.prototype.back=function(){return this.D.K?this.D.K.F:void 0},K.prototype.insert=function(t,i){return this.it(t,void 0,i)},K.prototype.find=function(t){t=this.vt(this.$,t);return new P(t,this.D)},K.prototype.lowerBound=function(t){t=this.st(this.$,t);return new P(t,this.D)},K.prototype.upperBound=function(t){t=this.ht(this.$,t);return new P(t,this.D)},K.prototype.reverseLowerBound=function(t){t=this.ut(this.$,t);return new P(t,this.D)},K.prototype.reverseUpperBound=function(t){t=this.ot(this.$,t);return new P(t,this.D)},K.prototype.union=function(t){var i=this;return t.forEach(function(t){i.insert(t)}),this.i},K.prototype[Symbol.iterator]=function(){return this.dt(this.$)};var vt,dt=K;function K(t,i,r){void 0===t&&(t=[]);var i=vt.call(this,i,r)||this,e=i;return t.forEach(function(t){e.insert(t)}),i}i(V,Dt=at),Object.defineProperty(V.prototype,"pointer",{get:function(){this.t===this.D&&o();var e=this;return new Proxy([],{get:function(t,i){return"0"===i?e.t.F:"1"===i?e.t.R:void 0},set:function(t,i,r){if("1"!==i)throw new TypeError("props must be 1");return e.t.R=r,!0}})},enumerable:!1,configurable:!0}),V.prototype.copy=function(){return new V(this.t,this.D,this.iteratorType)};var Dt,R=V;function V(){return null!==Dt&&Dt.apply(this,arguments)||this}i(A,wt=B),A.prototype.dt=function(i){return r(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,u(this.dt(i.J))];case 1:return t.sent(),[4,[i.F,i.R]];case 2:return t.sent(),[5,u(this.dt(i.K))];case 3:return t.sent(),[2]}})},A.prototype.begin=function(){return new R(this.D.J||this.D,this.D)},A.prototype.end=function(){return new R(this.D,this.D)},A.prototype.rBegin=function(){return new R(this.D.K||this.D,this.D,1)},A.prototype.rEnd=function(){return new R(this.D,this.D,1)},A.prototype.front=function(){var t;if(0!==this.i)return[(t=this.D.J).F,t.R]},A.prototype.back=function(){var t;if(0!==this.i)return[(t=this.D.K).F,t.R]},A.prototype.lowerBound=function(t){t=this.st(this.$,t);return new R(t,this.D)},A.prototype.upperBound=function(t){t=this.ht(this.$,t);return new R(t,this.D)},A.prototype.reverseLowerBound=function(t){t=this.ut(this.$,t);return new R(t,this.D)},A.prototype.reverseUpperBound=function(t){t=this.ot(this.$,t);return new R(t,this.D)},A.prototype.setElement=function(t,i,r){return this.it(t,i,r)},A.prototype.find=function(t){t=this.vt(this.$,t);return new R(t,this.D)},A.prototype.getElementByKey=function(t){return this.vt(this.$,t).R},A.prototype.union=function(t){var i=this;return t.forEach(function(t){i.setElement(t[0],t[1])}),this.i},A.prototype[Symbol.iterator]=function(){return this.dt(this.$)};var wt,at=A;function A(t,i,r){void 0===t&&(t=[]);var i=wt.call(this,i,r)||this,e=i;return t.forEach(function(t){e.setElement(t[0],t[1])}),i}function mt(t){var i=typeof t;return"object"==i&&null!==t||"function"==i}i(gt,Et=e);var Et,B=gt;function gt(t,i,r){r=Et.call(this,r)||this;return r.t=t,r.D=i,0===r.iteratorType?(r.pre=function(){return this.t.m===this.D&&o(),this.t=this.t.m,this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.V,this}):(r.pre=function(){return this.t.V===this.D&&o(),this.t=this.t.V,this},r.next=function(){return this.t===this.D&&o(),this.t=this.t.m,this}),r}i(U,Bt=_),U.prototype.P=function(t){var i=t.m,r=t.V;(i.V=r).m=i,t===this.j&&(this.j=r),t===this.N&&(this.N=i),--this.i},U.prototype.it=function(t,i,r){var e;if(r=void 0===r?mt(t):r){r=t[this.HASH_TAG];if(void 0!==r)return this.lt[r].R=i,this.i;Object.defineProperty(t,this.HASH_TAG,{value:this.lt.length,configurable:!0}),e={F:t,R:i,m:this.N,V:this.D},this.lt.push(e)}else{r=this.wt[t];if(r)return r.R=i,this.i;e={F:t,R:i,m:this.N,V:this.D},this.wt[t]=e}return 0===this.i?(this.j=e,this.D.V=e):this.N.V=e,this.N=e,this.D.m=e,++this.i},U.prototype.vt=function(t,i){return(i=void 0===i?mt(t):i)?void 0===(i=t[this.HASH_TAG])?this.D:this.lt[i]:this.wt[t]||this.D},U.prototype.clear=function(){var i=this.HASH_TAG;this.lt.forEach(function(t){delete t.F[i]}),this.lt=[],this.wt={},Object.setPrototypeOf(this.wt,null),this.i=0,this.j=this.N=this.D.m=this.D.V=this.D},U.prototype.eraseElementByKey=function(t,i){var r;if(i=void 0===i?mt(t):i){i=t[this.HASH_TAG];if(void 0===i)return!1;delete t[this.HASH_TAG],r=this.lt[i],delete this.lt[i]}else{if(void 0===(r=this.wt[t]))return!1;delete this.wt[t]}return this.P(r),!0},U.prototype.eraseElementByIterator=function(t){var i=t.t;return i===this.D&&o(),this.P(i),t.next()},U.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return this.P(i),this.i};var Bt,e=U;function U(){var t=Bt.call(this)||this;return t.lt=[],t.wt={},t.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(t.wt,null),t.D={},t.D.m=t.D.V=t.j=t.N=t.D,t}i(G,bt=B),Object.defineProperty(G.prototype,"pointer",{get:function(){return this.t===this.D&&o(),this.t.F},enumerable:!1,configurable:!0}),G.prototype.copy=function(){return new G(this.t,this.D,this.iteratorType)};var bt,j=G;function G(){return null!==bt&&bt.apply(this,arguments)||this}i(F,Pt=e),F.prototype.begin=function(){return new j(this.j,this.D)},F.prototype.end=function(){return new j(this.D,this.D)},F.prototype.rBegin=function(){return new j(this.N,this.D,1)},F.prototype.rEnd=function(){return new j(this.D,this.D,1)},F.prototype.front=function(){return this.j.F},F.prototype.back=function(){return this.N.F},F.prototype.insert=function(t,i){return this.it(t,void 0,i)},F.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return i.F},F.prototype.find=function(t,i){t=this.vt(t,i);return new j(t,this.D)},F.prototype.forEach=function(t){for(var i=0,r=this.j;r!==this.D;)t(r.F,i++,this),r=r.V},F.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:i=this.j,t.label=1;case 1:return i===this.D?[3,3]:[4,i.F];case 2:return t.sent(),i=i.V,[3,1];case 3:return[2]}})}.bind(this)()};var Pt,_=F;function F(t){void 0===t&&(t=[]);var i=Pt.call(this)||this,r=i;return t.forEach(function(t){r.insert(t)}),i}i(Kt,Jt=B),Object.defineProperty(Kt.prototype,"pointer",{get:function(){this.t===this.D&&o();var e=this;return new Proxy([],{get:function(t,i){return"0"===i?e.t.F:"1"===i?e.t.R:void 0},set:function(t,i,r){if("1"!==i)throw new TypeError("props must be 1");return e.t.R=r,!0}})},enumerable:!1,configurable:!0}),Kt.prototype.copy=function(){return new Kt(this.t,this.D,this.iteratorType)};var Jt,x=Kt;function Kt(){return null!==Jt&&Jt.apply(this,arguments)||this}i($,Rt=e),$.prototype.begin=function(){return new x(this.j,this.D)},$.prototype.end=function(){return new x(this.D,this.D)},$.prototype.rBegin=function(){return new x(this.N,this.D,1)},$.prototype.rEnd=function(){return new x(this.D,this.D,1)},$.prototype.front=function(){if(0!==this.i)return[this.j.F,this.j.R]},$.prototype.back=function(){if(0!==this.i)return[this.N.F,this.N.R]},$.prototype.setElement=function(t,i,r){return this.it(t,i,r)},$.prototype.getElementByKey=function(t,i){return(i=void 0===i?mt(t):i)?void 0!==(i=t[this.HASH_TAG])?this.lt[i].R:void 0:(i=this.wt[t])?i.R:void 0},$.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return[i.F,i.R]},$.prototype.find=function(t,i){t=this.vt(t,i);return new x(t,this.D)},$.prototype.forEach=function(t){for(var i=0,r=this.j;r!==this.D;)t([r.F,r.R],i++,this),r=r.V},$.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:i=this.j,t.label=1;case 1:return i===this.D?[3,3]:[4,[i.F,i.R]];case 2:return t.sent(),i=i.V,[3,1];case 3:return[2]}})}.bind(this)()};var Rt,B=$;function $(t){void 0===t&&(t=[]);var i=Rt.call(this)||this,r=i;return t.forEach(function(t){r.setElement(t[0],t[1])}),i}t.Deque=Q,t.HashMap=B,t.HashSet=_,t.LinkList=H,t.OrderedMap=at,t.OrderedSet=dt,t.PriorityQueue=n,t.Queue=it,t.Stack=q,t.Vector=Y,Object.defineProperty(t,"_t",{value:!0})});
//# sourceMappingURL=js-sdsl.min.js.map
